//2009/08/20 20:05:05
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class CyclesInPermutations
{
public:
    int maxCycle(vector <int> board)
    {
		int ret = -1;
		for(int i=0; i<board.size(); i++)
		{
			vector<int> v(board);
			int temp = 0;
			for(int j=i; v[j]!=-1;)
			{
				cout << v[j] << " ";
				int pos = v[j] - 1;
				v[j] = -1;
				j = pos;
				temp ++;
			}
			cout << endl;
			if(ret < temp || ret == -1) ret = temp;
		}
		return ret;
    }
};
